home *** CD-ROM | disk | FTP | other *** search
- Path: fido.asd.sgi.com!austern
- From: kanze@lts.sel.alcatel.de (James Kanze US/ESC 60/3/141 #40763)
- Newsgroups: comp.std.c++
- Subject: Re: 'const' binding to specifier in declaration list
- Followup-To: comp.std.c++
- Date: 17 Apr 1996 10:41:47 PDT
- Organization: GABI Software, Sarl.
- Approved: austern@isolde.mti.sgi.com
- Message-ID: <KANZE.96Apr17121453@slsvgqt.lts.sel.alcatel.de>
- References: <3173B383.41C67EA6@rstcorp.com>
- NNTP-Posting-Host: isolde.mti.sgi.com
- X-Original-Date: 17 Apr 1996 10:14:53 GMT
- In-Reply-To: "Aaron S. Binns"'s message of 16 Apr 1996 13:17:21 PDT
- Apparently-To: std-c++@ncar.UCAR.EDU
- X-Auth: PGPMoose V1.1 PGP comp.std.c++
- iQBVAwUBMXUtXEy4NqrwXLNJAQFrCwIAvyqTcA0n2cEcmFev2sa1jpGXlo/WAxoW
- COfFSMosvCSIBZGcaAQGSiygbFipEh4HWDBTspYdhSI6eHN7BxM8Zw==
- =eI/Y
- Originator: austern@isolde.mti.sgi.com
-
- In article <3173B383.41C67EA6@rstcorp.com> "Aaron S. Binns"
- <asbinn@rstcorp.com> writes:
-
- |> [Moderator's note: This is crossposted to comp.std.c++ and
- |> comp.lang.c++, and followups have been set to comp.std.c++. mha]
-
- |> I recently came across a piece of code that reads:
-
- |> class A {
- |> // contents of class A
- |> } a1, *a2, const *a3;
-
- While I personally wouldn't write anything like this, it is definitly
- legal.
-
- |> This looks pretty bogus to me. I thought that the 'const' applied
- |> to the elaborated specifier 'class A'. If the 'const' qualifier is
- |> supposed to apply to the pointer in 'a3', then it should come _after_
- |> the '*'.
-
- No, it is the A being pointed to that is const, not the pointer.
-
- Separating each of the definitions out into a separate statement makes
- this obvious:
-
- class A { ... } ;
- A a1 ;
- A* a2 ;
- A const* a3 ;
-
- |> I think that either one of the two following was intended.
-
- |> 1)
-
- |> class A {
- |> // contents of class A
- |> } a1, *a2, * const a3;
-
-
- |> 2)
-
- |> class A {
- |> // contents of class A
- |> } a1, *a2;
-
- |> A const *a3; // Or const A *a3;
-
- Regardless of what was intended, 2 is the interpretation required by
- the draft standard (and by the C standard).
- --
- James Kanze Tel.: (+33) 88 14 49 00 email: kanze@gabi-soft.fr
- GABI Software, Sarl., 8 rue des Francs-Bourgeois, F-67000 Strasbourg, France
- Conseils, itudes et rialisations en logiciel orienti objet --
- -- A la recherche d'une activiti dans une region francophone
- ---
- [ comp.std.c++ is moderated. To submit articles: Try just posting with your
- newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
- comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
- Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
- Comments? mailto:std-c++-request@ncar.ucar.edu
- ]
-